home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxpcolor.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  7.6 KB  |  216 lines

  1. /* Copyright (C) 1993, 1995, 1996, 1997, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxpcolor.h,v 1.2 2000/09/19 19:00:39 lpd Exp $ */
  20. /* Pattern color and tile structures and procedures */
  21. /* Requires gsmatrix.h, gxcolor2.h, gxdcolor.h */
  22.  
  23. #ifndef gxpcolor_INCLUDED
  24. #  define gxpcolor_INCLUDED
  25.  
  26. #include "gspcolor.h"
  27. #include "gxcspace.h"
  28. #include "gxdevice.h"
  29. #include "gxdevmem.h"
  30. #include "gxpcache.h"
  31.  
  32. /*
  33.  * Define the type of a Pattern, also used with Pattern instances.
  34.  */
  35. #ifndef gs_pattern_type_DEFINED
  36. #  define gs_pattern_type_DEFINED
  37. typedef struct gs_pattern_type_s gs_pattern_type_t;
  38. #endif
  39. struct gs_pattern_type_s {
  40.     int PatternType;
  41.     struct pp_ {
  42.  
  43.     /*
  44.      * Define whether a Pattern uses the base color space in its color
  45.      * space, requiring setcolor to provide values for the base color
  46.      * space.  Currently this is true for uncolored PatternType 1
  47.      * patterns, false for all others.
  48.      */
  49.  
  50. #define pattern_proc_uses_base_space(proc)\
  51.   bool proc(P1(const gs_pattern_template_t *))
  52.  
  53.     pattern_proc_uses_base_space((*uses_base_space));
  54.  
  55.     /*
  56.      * Make an instance of a Pattern.
  57.      */
  58.  
  59. #define pattern_proc_make_pattern(proc)\
  60.   int proc(P5(gs_client_color *, const gs_pattern_template_t *,\
  61.           const gs_matrix *, gs_state *, gs_memory_t *))
  62.  
  63.     pattern_proc_make_pattern((*make_pattern));
  64.  
  65.     /*
  66.      * Get the template from a Pattern instance.
  67.      */
  68.  
  69. #define pattern_proc_get_pattern(proc)\
  70.   const gs_pattern_template_t *proc(P1(const gs_pattern_instance_t *))
  71.  
  72.     pattern_proc_get_pattern((*get_pattern));
  73.  
  74.     /*
  75.      * Remap a Pattern color to a device color.
  76.      * cs_proc_remap_color is defined in gxcspace.h.
  77.      */
  78.  
  79. #define pattern_proc_remap_color(proc)\
  80.   cs_proc_remap_color(proc)
  81.  
  82.     pattern_proc_remap_color((*remap_color));
  83.  
  84.     } procs;
  85. };
  86.  
  87. /*
  88.  * Initialize the common part of a pattern template.  This procedure is for
  89.  * the use of gs_pattern*_init implementations, not clients.
  90.  */
  91. void gs_pattern_common_init(P2(gs_pattern_template_t *,
  92.                    const gs_pattern_type_t *));
  93.  
  94. /*
  95.  * Do the generic work for makepattern: allocate the instance and the
  96.  * saved graphics state, and fill in the common members.
  97.  */
  98. int gs_make_pattern_common(P6(gs_client_color *, const gs_pattern_template_t *,
  99.                   const gs_matrix *, gs_state *, gs_memory_t *,
  100.                   gs_memory_type_ptr_t));
  101.  
  102. /* Declare the freeing procedure for Pattern instances. */
  103. extern rc_free_proc(rc_free_pattern_instance);
  104.  
  105. /* Declare the Pattern color space type. */
  106. extern const gs_color_space_type gs_color_space_type_Pattern;
  107.  
  108. /*
  109.  * Define the (PatternType 1) Pattern device color types.  There is one type
  110.  * for colored patterns, and one uncolored pattern type for each non-Pattern
  111.  * device color type.
  112.  */
  113. extern const gx_device_color_type_t
  114.     gx_dc_pattern,
  115.     gx_dc_pure_masked, gx_dc_binary_masked, gx_dc_colored_masked;
  116.  
  117. #define gx_dc_type_pattern (&gx_dc_pattern)
  118.  
  119. /*
  120.  * Define a color tile, an entry in the rendered Pattern cache (and
  121.  * eventually in the colored halftone cache).  Note that the depth is
  122.  * not sufficient to ensure that the rendering matches a given device;
  123.  * however, we don't currently have an object that represents the
  124.  * abstraction of a 'color representation'.
  125.  */
  126. struct gx_color_tile_s {
  127.     /* ------ The following are the 'key' in the cache. ------ */
  128.     /* Note that the id is a generated instance ID, */
  129.     /* and has no relation to the template's gs_uid. */
  130.     gx_bitmap_id id;
  131.     int depth;
  132.     /* We do, however, copy the template's gs_uid, */
  133.     /* for use in selective cache purging. */
  134.     gs_uid uid;
  135.     /* ------ The following are the cache 'value'. ------ */
  136.     /* Note that if tbits and tmask both have data != 0, */
  137.     /* both must have the same rep_shift. */
  138. /****** NON-ZERO shift VALUES ARE NOT SUPPORTED YET. ******/
  139.     int tiling_type;        /* TilingType */
  140.     gs_matrix step_matrix;    /* tiling space -> device space, */
  141.     /* see gxcolor2.h for details */
  142.     gs_rect bbox;        /* bbox of tile in tiling space */
  143.     gx_strip_bitmap tbits;    /* data = 0 if uncolored */
  144.     gx_strip_bitmap tmask;    /* data = 0 if no mask */
  145.     /* (i.e., the mask is all 1's) */
  146.     bool is_simple;        /* true if xstep/ystep = tile size */
  147.     /* The following is neither key nor value. */
  148.     uint index;            /* the index of the tile within */
  149.     /* the cache (for GC) */
  150. };
  151.  
  152. #define private_st_color_tile()    /* in gxpcmap.c */\
  153.   gs_private_st_ptrs2(st_color_tile, gx_color_tile, "gx_color_tile",\
  154.     color_tile_enum_ptrs, color_tile_reloc_ptrs, tbits.data, tmask.data)
  155. #define private_st_color_tile_element()    /* in gxpcmap.c */\
  156.   gs_private_st_element(st_color_tile_element, gx_color_tile,\
  157.     "gx_color_tile[]", color_tile_elt_enum_ptrs, color_tile_elt_reloc_ptrs,\
  158.     st_color_tile)
  159.  
  160. /* Define the Pattern cache. */
  161. /*#include "gxpcache.h" *//* (above) */
  162.  
  163. /* Allocate a Pattern cache. */
  164. /* We shorten the procedure names because some VMS compilers */
  165. /* truncate names to 23 characters. */
  166. uint gx_pat_cache_default_tiles(P0());
  167. ulong gx_pat_cache_default_bits(P0());
  168. gx_pattern_cache *gx_pattern_alloc_cache(P3(gs_memory_t *, uint, ulong));
  169.  
  170. /* Get or set the Pattern cache in a gstate. */
  171. gx_pattern_cache *gstate_pattern_cache(P1(gs_state *));
  172. void gstate_set_pattern_cache(P2(gs_state *, gx_pattern_cache *));
  173.  
  174. /*
  175.  * Define a device for accumulating the rendering of a Pattern.
  176.  * This is actually a wrapper for two other devices: one that accumulates
  177.  * the actual pattern image (if this is a colored pattern), and one that
  178.  * accumulates a mask defining which pixels in the image are set.
  179.  */
  180. typedef struct gx_device_pattern_accum_s {
  181.     gx_device_forward_common;
  182.     /* Client sets these before opening */
  183.     gs_memory_t *bitmap_memory;
  184.     const gs_pattern1_instance_t *instance;
  185.     /* open sets these */
  186.     gx_device_memory *bits;    /* target also points to bits */
  187.     gx_device_memory *mask;
  188. } gx_device_pattern_accum;
  189.  
  190. #define private_st_device_pattern_accum() /* in gxpcmap.c */\
  191.   gs_private_st_suffix_add3_final(st_device_pattern_accum,\
  192.     gx_device_pattern_accum, "pattern accumulator", pattern_accum_enum,\
  193.     pattern_accum_reloc, gx_device_finalize, st_device_forward,\
  194.     instance, bits, mask)
  195.  
  196. /* Allocate a pattern accumulator. */
  197. gx_device_pattern_accum *gx_pattern_accum_alloc(P2(gs_memory_t * memory, client_name_t));
  198.  
  199. /* Add an accumulated pattern to the cache. */
  200. /* Note that this does not free any of the data in the accumulator */
  201. /* device, but it may zero out the bitmap_memory pointers to prevent */
  202. /* the accumulated bitmaps from being freed when the device is closed. */
  203. int gx_pattern_cache_add_entry(P3(gs_imager_state *, gx_device_pattern_accum *,
  204.                   gx_color_tile **));
  205.  
  206. /* Look up a pattern color in the cache. */
  207. bool gx_pattern_cache_lookup(P4(gx_device_color *, const gs_imager_state *,
  208.                 gx_device *, gs_color_select_t));
  209.  
  210. /* Purge selected entries from the pattern cache. */
  211. void gx_pattern_cache_winnow(P3(gx_pattern_cache *,
  212.                 bool (*)(P2(gx_color_tile *, void *)),
  213.                 void *));
  214.  
  215. #endif /* gxpcolor_INCLUDED */
  216.